/***************************************************************************
 * 文件名:PageModel.java<br>
 * 版本: <br>
 * 描述: <br>
 * 版权所有: <br>
 * //////////////////////////////////////////////////////// <br>
 * 创建者: robo<br>
 * 创建日期: 2010-11-10 <br>
 * 修改者: <br>
 * 修改日期: <br>
 * 修改说明: <br>
 **************************************************************************/
package com.sunwayhorizo.health.ets.base.common;

import java.io.Serializable;
import java.util.List;

public class PageModel implements Serializable {

	private static final long serialVersionUID = 1L;
	
	/**
	 * 当前第几页
	 */
	private int toPage;

	/**
	 * 总共记录数
	 */
	private int totalRecords;

	/**
	 * 每页显示记录数
	 */
	private int pageSize;

	/**
	 * 总共页数
	 */
	private int totalPage;

	/**
	 * 起始记录数
	 */
	private int beginIndex;
	
	private List<?> list; 
	
	public PageModel(){
		
	}
	
	public PageModel(int toPage, int pageSize) {	
		// 判断当前页是否为0
		if (toPage == 0) {
			// 如为0 将当前页修改为1
			this.toPage = 1;
		} else {
			this.toPage = toPage;
		}
		this.pageSize = pageSize;
	}
	
	public int getBeginIndex() {
		beginIndex = (toPage - 1) * pageSize;
		return beginIndex;
	}

	public void setBeginIndex(int beginIndex) {
		this.beginIndex = beginIndex;
	}
	
	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getToPage() {
		return toPage;
	}

	public void setToPage(int toPage) {
		this.toPage = toPage;
	}
	
	public int getTotalPage() {
		// 计算总页数 只取整数
		totalPage = totalRecords / pageSize;
		// 判断是否还有数据
		if (totalRecords % pageSize != 0) {
			// 当前页数加1
			totalPage++;
		}
		// 判断总页数是否为0.
		if (totalPage == 0) {
			// 为0时修改为1.
			totalPage = 1;
		}
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}
	
	

}


